import React, { useState } from 'react'
import { useDispatch } from 'react-redux';
const Index = () => {
  const [value, setValue] = useState();
  const dispatch = useDispatch()
  const add = () => {
    dispatch({ type: 'add', payload: value })
  }
  return (
    <div style={{ display: 'flex' }}>
      <input value={value} onChange={e => setValue(e.target.value)} type="text" placeholder='请输入内容' style={{ flex: 1 }} />
      <button onClick={add}>添加</button>
    </div>
  )
}

export default Index